<?php
/**
 * Created by PhpStorm
 * User: honglin
 * Date: 2022/8/8
 * Time: 下午3:04
 */

namespace App\Controller\Ocean;

use App\Middleware\AuthTokenMiddleware;
use App\Service\Ocean\OceanTaskService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @Middleware(AuthTokenMiddleware::class)
 * @ApiController(prefix="ocean/task")
 */
class OceanTaskController extends BaseController
{
    /**
     * @Inject()
     * @var OceanTaskService
     */
    protected $oceanTaskService;

    /**
     * @PostApi(path="lists")
     */
    public function lists()
    {

    }


    /**
     * @PostApi(path="get-user-task-lists")
     */
    public function getUserTaskLists()
    {
        $userId = $this->getUid();
        $data = $this->oceanTaskService->getUserTaskLists($userId);
        _SUCCESS($data);
    }

    /**
     * @PostApi(path="sign-in")
     */
    public function SignIn()
    {
        $userId = $this->getUid();
        $this->oceanTaskService->signIn($userId);
        _SUCCESS();
    }

    /**
     * @PostApi(path="ad")
     */
    public function Ad()
    {
        $userId = $this->getUid();
        $this->oceanTaskService->Ad($userId);
        _SUCCESS();
    }


    /**
     * @PostApi(path="finish")
     * @FormData(key="task_id")
     */
    public function finish()
    {
        $userId = $this->getUid();
        $task_id = $this->getParams()->get('task_id');
        $this->oceanTaskService->finish($userId, $task_id);
        _SUCCESS();
    }

}